<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String title = "ETB基础开发平台";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<title><%=title %></title>
<head>
	<link rel="stylesheet" type="text/css" href="${path}/common/component/eui/themes/default/eui.css">
	<link rel="stylesheet" type="text/css" href="${path}/common/component/eui/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="${path}/skin/etb.css" />
	<link rel="stylesheet" type="text/css" href="${path}/skin/blue/base.css" />
	<link rel="stylesheet" type="text/css" href="${path}/skin/blue/default.css" />
	<script type="text/javascript" src="${path}/common/component/eui/jquery.min.js"></script>
	<script type="text/javascript" src="${path}/common/component/eui/jquery.collection.js"></script>
	<script type="text/javascript" src="${path}/common/component/eui/jquery.common.js"></script>
	<script type="text/javascript" src="${path}/common/component/eui/jquery.eui.min.js?${path}"></script>
	<script type="text/javascript" src="${path}/common/component/eui/locale/eui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="${path}/common/component/eui/extend/jquery.eui.extend.js"></script>
	<script type="text/javascript" src="${path}/common/component/eui/extend/jquery.validate.js"></script>
	<script type="text/javascript" src="${path}/common/component/eui/extend/jquery.dialog.js"></script>
</head>
<body class="eui-layout" id="system">
	<div data-options="region:'north',border:false" style="overflow:hidden;">
		<div class="header clearfix">
			<dl>
				<dt><a href="javascript:void(0)"><img src="${path}/skin/green/images/logo2.png" width="50px" height="50px" style="margin-left:30px"/></a><span style="color:#fff;font-family:楷体;font-size:30px"><%=title %></span></dt>
				<dd>
					<span style="color:#fff;">您好：${party.displayName}</span>
					<span style="color:#fff;">|</span>
					<a href="javascript:modifyPsw()" target="_top" class="psw">修改密码</a>
					<span style="color:#fff;">|</span>
					<a href="http://localhost:8081/logout?service=http://localhost:8080/wisdom/eframe/auth/index.jsp" target="_top" class="exit">退出</a>
				</dd>
			</dl>
		</div>
		<div class="nav clearfix top-menu">
			<ul class="right">
			</ul>
		</div>
	</div>
	<div data-options="region:'west',split:false,title:'隐藏菜单'," style="width:155px;" id="leftmenu">
		<div class="sidebar left-menu">
			<ul class="menu">
				<li></li>
			</ul>
		</div>
	</div>
	<div data-options="region:'center'" style="padding:5px" id="workspace">
	</div>
	<div data-options="region:'south',border:false" class="footer" style="color:#fff;">版权所属：北京鼎丰科技有限公司</div>
</body>

<script>
//菜单容器
var menuDatas = new Map();
//菜单关系容器
var menuRelation = new Map();
eui.ajax({
	url: '${path}/auth!getMenuData.action',
	success: function(data) {
		var topMenuUl = $(".top-menu").find("ul");
		var menuLi = $(".menu").children();
		
		eval("data = "+data);
		for(var i=0,size=data.length; i<size; i++) {
			var menuData = data[i];
			//把菜单放进关系容器管理
			menuDatas.put(menuData.id, menuData);
			if(menuData.menulevel == 1) {
				//生成第一级菜单
				if(i!=0) topMenuUl.append('<li><span><img src="${path}/skin/green/images/nav_line.png" /></span></li>');
				topMenuUl.append('<li><a href="javascript:void(0)" url="'+menuData.funcuri+'" id="'+menuData.id+'">'+menuData.displayname+'</a></li>');
				//把一级菜单放进关系容器管理
				menuRelation.put(menuData.id, new List());
			}
		}
		for(var i=0,size=data.length; i<size; i++) {
			var menuData = data[i];
			if(menuData.menulevel == 2) {
				//生成第二级菜单
				menuLi.append('<dl><dt><a href="javascript:void(0)" url="'+menuData.funcuri+'" id="'+menuData.id+'">'+menuData.displayname+'</a></dt></dl>');
				//把二级菜单放进关系容器管理
				menuRelation.get(menuData.uplevelid).add(menuData.id);
			}
		}
		for(var i=0,size=data.length; i<size; i++) {
			var menuData = data[i];
			if(menuData.menulevel == 3) {
				//生成第三级菜单
				$("#"+menuData.uplevelid).closest("dl").append('<dd><ul class="module_m"><li><a href="javascript:void(0)" url="'+menuData.funcuri+'" id="'+menuData.id+'">'+menuData.displayname+'</a></li></ul></dd>');
			}
		}
		
		
		
		$(".top-menu").find("a").click(function(){
			if($(this).attr("url")) {
				var menu = menuDatas.get($(this).attr("id"));
				var url;
				//不同的路径类型
				if(menu.functype == 'page') {
					url = '${fullPath}' + $(this).attr("url");
				} else if(menu.functype == 'external') {
					url = $(this).attr("url");
				}
				//不同的打开方式
				if(menu.opentype == 'normal') {
					hideSecondMenu();
					//menuLi.find("dl").removeClass("current");
					//$('#workspace').panel('refresh', url);
					if(menu.functype == 'external') {
						$('#workspace').panel('iframe', url);
					} else {
						$('#workspace').panel('refresh', url);
					}
				} else if(menu.opentype == 'window') {
					window.open(url);
				} else if(menu.opentype == 'dialog') {
					dialog.open({url:url,buttons:false,width:1000,height:500,iframe:(menu.functype == 'external')});
				} else if(menu.opentype == 'parent') {
					menuLi.find("dl").hide();
					showSecondMenu();
					var i=0;
					menuRelation.get($(this).attr("id")).each(function(sencondMenuId){
						if(i==0) {
							$("#"+sencondMenuId).click();
						}
						$("#"+sencondMenuId).closest("dl").show();
						i++;
					});
				}
			}
		});
		
		$(".top-menu").find("a").click(function() {
			$(".top-menu").find("a").removeClass("selected");
			$(this).addClass("selected");
		});

		$(".menu").find("dl").click(function() {
			$(".menu").find("dl").removeClass("current");
			$(this).addClass("current");
		});

		$(".menu").find("dd").click(function() {
			$(".menu").find("dd").removeClass("ddcurrent");
			$(this).addClass("ddcurrent");
		});

		$(".menu").find("a").click(function(){
			if($(this).attr("url")) {
				var menu = menuDatas.get($(this).attr("id"));
				var url;
				//不同的路径类型
				if(menu.functype == 'page') {
					url = '${fullPath}' + $(this).attr("url");
				} else if(menu.functype == 'external') {
					url = $(this).attr("url");
				}
				//不同的打开方式
				if(menu.opentype == 'normal') {
					if(menu.functype == 'external') {
						$('#workspace').panel('iframe', url);
					} else {
						$('#workspace').panel('refresh', url);
					}
				} else if(menu.opentype == 'window') {
					window.open(url);
				} else if(menu.opentype == 'dialog') {
					dialog.open({url:url,buttons:false,width:1000,height:500,iframe:(menu.functype == 'external')});
				}
			}
		});
		
		//默认显示第一菜单项
		$(".top-menu").find("a")[0].click();
	}
});

function showSecondMenu(){
	$('#system').layout('show','west');  
}
function hideSecondMenu(){
	$('#system').layout('hidden','west');  
}
$.parser.auto=true;

function modifyPsw() {
	dialog.open({
		width:400,
		height:210,
		url:'${path}/eframe/rights/etbuser/psw.ftl'
	});
}

</script>
</html>